package com.menu.system.service.impl;

import com.menu.common.utils.DateUtils;
import com.menu.system.domain.MenuGoods;
import com.menu.system.mapper.MenuGoodsMapper;
import com.menu.system.service.IMenuGoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 菜单权限Service业务层处理
 *
 * @author ruoyi
 * @date 2024-06-05
 */
@Service
public class MenuGoodsServiceImpl implements IMenuGoodsService {
    @Autowired
    private MenuGoodsMapper menuGoodsMapper;

    /**
     * 查询菜单权限
     *
     * @param goodsId 菜单权限主键
     * @return 菜单权限
     */
    @Override
    public MenuGoods selectMenuGoodsByGoodsId(Long goodsId) {
        return menuGoodsMapper.selectMenuGoodsByGoodsId(goodsId);
    }

    /**
     * 查询菜单权限列表
     *
     * @param menuGoods 菜单权限
     * @return 菜单权限
     */
    @Override
    public List<MenuGoods> selectMenuGoodsList(MenuGoods menuGoods) {
        return menuGoodsMapper.selectMenuGoodsList(menuGoods);
    }

    /**
     * 新增菜单权限
     *
     * @param menuGoods 菜单权限
     * @return 结果
     */
    @Override
    public int insertMenuGoods(MenuGoods menuGoods) {
        menuGoods.setCreateTime(DateUtils.getNowDate());
        return menuGoodsMapper.insertMenuGoods(menuGoods);
    }

    /**
     * 修改菜单权限
     *
     * @param menuGoods 菜单权限
     * @return 结果
     */
    @Override
    public int updateMenuGoods(MenuGoods menuGoods) {
        menuGoods.setUpdateTime(DateUtils.getNowDate());
        return menuGoodsMapper.updateMenuGoods(menuGoods);
    }

    /**
     * 批量删除菜单权限
     *
     * @param goodsIds 需要删除的菜单权限主键
     * @return 结果
     */
    @Override
    public int deleteMenuGoodsByGoodsIds(Long[] goodsIds) {
        return menuGoodsMapper.deleteMenuGoodsByGoodsIds(goodsIds);
    }

    /**
     * 删除菜单权限信息
     *
     * @param goodsId 菜单权限主键
     * @return 结果
     */
    @Override
    public int deleteMenuGoodsByGoodsId(Long goodsId) {
        return menuGoodsMapper.deleteMenuGoodsByGoodsId(goodsId);
    }
}
